Skip to content

Define getrowval and getnzval for sparse vectors - #805

Merged
ViralBShah merged 10 commits into
mainfrom
vs/getrowval-sparsevector
Sep 19, 2026
Merged

ViralBShah merged 10 commits into
mainfrom
vs/getrowval-sparsevector

Conversation

@ViralBShah

@ViralBShah ViralBShah commented Sep 10, 2026

Copy link
Copy Markdown
Member

Fixes #172.

rowvals(x::SparseVectorUnion) already existed, but getrowval and getnzval (the accessors used throughout linalg.jl) only had AbstractSparseMatrixCSC methods. This adds the SparseVectorUnion methods, forwarding to nonzeroinds and nonzeros, so both accessor families cover both matrices and vectors (including column views and whole-vector views).

It also documents and exports getrowval and getnzval, whose names match the rowval and nzval fields of SparseMatrixCSC:

  • New docstrings with matrix and vector examples, added to the API section of the docs.
  • Both names exported.
  • Triangular-wrapper forwards added so the new names cover everything rowvals and nonzeros do.
  • Existing uses of rowvals and nonzeros, including the nzrange example, are left as they are, and no deprecation of rowvals or nonzeros is announced here.

Tests added to the existing basic properties testset in test/sparsevector.jl. Doctests and the Documenter build pass locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Lbrk9jqFT4HCx4ENQdtx6f

`rowvals` already covers `SparseVectorUnion`, but the `getrowval` and
`getnzval` accessors used throughout linalg.jl only had matrix methods.
Add the vector methods so both accessor families cover both types.

Fixes #172

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lbrk9jqFT4HCx4ENQdtx6f
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (7c9195a) to head (7aea10c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #805   +/-   ##
=======================================
  Coverage   92.55%   92.55%           
=======================================
  Files          12       12           
  Lines        8728     8734    +6     
=======================================
+ Hits         8078     8084    +6     
  Misses        650      650           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ViralBShah and others added 2 commits September 10, 2026 09:54
Add docstrings and docs entries for `getrowval` and `getnzval`, mark them
`public`, and forward them through triangular wrappers like `rowvals` and
`nonzeros` already are. Note in the `rowvals` and `nonzeros` docstrings
that the new names match the `SparseMatrixCSC` fields and that the old
names are likely to be deprecated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lbrk9jqFT4HCx4ENQdtx6f
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lbrk9jqFT4HCx4ENQdtx6f
@matbesancon

Copy link
Copy Markdown
Contributor

@ViralBShah I just fixed a conflict with the same implementation of rowvals but I realize that it would be preferable to homogenize all methods to use a SparseVectorOrView argument?

@ViralBShah

Copy link
Copy Markdown
Member Author

@matbesancon agreed, done in 947cb73: the new vector methods and the triangular forwards now dispatch on SparseVectorOrView / SparseMatrixCSCOrView, matching rowvals and nonzeros (the *Union names are only kept for downstream). Also merged main (the cscimport doctest conflict resolves to main's version) and added a LowerTriangular case for the lines Codecov flagged.

Written by Claude Code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread src/sparsematrix.jl
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ViralBShah
ViralBShah merged commit 027fe7a into main Sep 19, 2026
10 checks passed
@ViralBShah
ViralBShah deleted the vs/getrowval-sparsevector branch September 19, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getrowval and getnzval are defined on SparseMatrixCSC but not on SparseVector

2 participants